package com.wc.算法提高课.A第一章_动态规划.背包模型.背包问题求方案数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/9 23:12
 * @description https://www.acwing.com/problem/content/11/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int P = (int) 1e9 + 7;
    static int N = 1010;
    // 保存当前最大价值的方案数
    static int[] g = new int[N];
    // 保存当天最大价值
    static int[] f = new int[N];
    static int n, m;


    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        g[0] = 1;
        while (n-- > 0) {
            int w = sc.nextInt(), v = sc.nextInt();
            for (int i = m; i >= w; i--) {
                if (f[i] < f[i - w] + v) {
                    f[i] = f[i - w] + v;
                    g[i] = g[i - w];
                } else if (f[i] == f[i - w] + v) {
                    g[i] = (g[i] + g[i - w]) % P;
                }
            }
        }
        // 求出最大价值,有其他体积满足最大价值的可能
        int res = 0;
        for (int i = 1; i <= m; i++) {
            if (f[i] > f[res]) res = i;
        }
        int sum = 0;
        for (int i = 0; i <= m; i++) {
            if (f[i] == f[res]) sum = (sum + g[i]) % P;
        }
        out.println(sum);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
